package com.qf.boot2203.config;


import com.qf.boot2203.filter.DemoFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FilterConfig {


    @Bean
    public FilterRegistrationBean<DemoFilter> demoFilterFilterRegistrationBean(){

        FilterRegistrationBean<DemoFilter> demoFilterFilterRegistrationBean = new FilterRegistrationBean<>();

        //配置拦截路径

        demoFilterFilterRegistrationBean.addUrlPatterns("/hello");

        //将filter加入到IOC容器

        demoFilterFilterRegistrationBean.setFilter(new DemoFilter());

        return demoFilterFilterRegistrationBean;
    }
}
